<?php
/**
 * User: YL
 * Date: 2019/09/12
 */

namespace App\Common\Controllers;

use Illuminate\Foundation\Application;
use Illuminate\Http\Request;
use restful\traits\CheckController;
use restful\traits\ResourceController;
use restful\traits\TokenController;

/**
 * @method TokenController initialize()
 */
class BaseController
{
    use CheckController;
    use TokenController;
    use ResourceController;

    /**
     * @var Application
     */
    protected $app;

    /**
     * @var Request
     */
    protected $request;

    /**
     * @var array
     */
    protected $params;

    public function __construct(Application $app, Request $request)
    {
        $this->app = $app;
        $this->request = $request;
        $this->params = $request->params ?? [];

        $this->initialize();
    }

    public function __call($name, $arguments)
    {
        $this->initialize();
        call_user_func_array([$this, $name], $arguments);
    }
}
